import request from '@/config/index';

const baseUrl = '/im/topic/user'

// 群聊列表
export const ApiChatList = (params) => {
	return request.get({ url: `/im/chat-list`, params })
}

// 创建
export const ApiChatAdd = (data) => {
	return request.post({ url: '/im/topic/create', data })
}

// 归档
export const ApiChatReturn = (topicId) => {
	return request.put({ url: `/im/topic/archive/${topicId}` })
}

// 删除
export const ApiChatDelete = (topicId) => {
	return request.delete({ url: `/im/topic/delete/${topicId}` })
}

// 群聊详情
export const ApiChatListDetail = (topicId) => {
	return request.get({ url: `/im/topic/get/${topicId}` })
}
// 群聊用户
export const ApiChatListDetailUser = (topicId) => {
	return request.get({ url: `/im/topic/user/${topicId}` })
}

// 群聊-发送消息
export const ApiChatSend = (data) => {
	return request.post({ url: `/im/topic/message/send`, data })
}

// 群聊-消息已读
export const ApiChatRead = (topicId) => {
	return request.put({ url: `/im/topic/message/read/${topicId}` })
}

// 群聊记录
export const ApiChatListRecord = (topicId, params) => {
	return request.get({ url: `/im/topic/message/${topicId}/cursor-page`, params })
}

// 群聊-绑定登录人
export const ApiChatBind = () => {
	return request.put({ url: `${baseUrl}/bind` })
}

// 群聊-绑定人
export const ApiChatUserBind = (data) => {
	return request.post({ url: `${baseUrl}/manager`, data })
}

// 群聊-拉人
export const ApiChatUserAdd = (topicId, data) => {
	return request.post({ url: `${baseUrl}/pull/${topicId}`, data })
}

// 群聊-踢人
export const ApiChatUserDelete = (topicId, params) => {
	return request.delete({ url: `${baseUrl}/kick/${topicId}?userIds=${params}` })
}

// 应用-系统通知分页
export const ApiNewsList = (params) => {
	return request.get({ url: `/im/system/message/cursor/page`, params })
}

// 系统消息已读
export const ApiNewsListRead = () => {
	return request.put({ url: `/im/system/message/read` })
}

// 应用-系统通知消息
export const ApiNewDetail = (params) => {
	return request.get({ url: `/im/system-message/newest`, params })
}

